{extend name="_public/table_page" /}

{block name="search-form"}
<div class="layui-row">
    <form class="layui-form layui-col-md12 we-search" action="{:request()->url()}" method="get">
        <div class="layui-inline">
            <select name="cid">
                <option value="">请选择所属分类</option>
                <option value="0" {eq name="$Request.get.cid" value="0"}selected{/eq}>未指定分类</option>
                {volist name="cates" id="c"}
                <option value="{$c.id}" {eq name="$Request.get.cid" value="$c.id"}selected{/eq}>{$c._pre}{$c.title}</option>
                {/volist}
            </select>
        </div>
        <div class="layui-inline">
            <input type="text" name="title" value="{$Request.get.title}" placeholder="请输入文章名（支持模糊搜索）" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-inline">
            <select name="state">
                <option value="">请选择文章状态</option>
                <option value="0" {eq name="$Request.get.state" value="0"}selected{/eq}>已禁用</option>
                <option value="1" {eq name="$Request.get.state" value="1"}selected{/eq}>已启用</option>
            </select>
        </div>
        <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
    </form>
</div>
{/block}

{block name="button"}
<div class="weadmin-block" style="overflow: hidden">
    {if auth("$classuri/rebuild")}
    <button class="layui-btn layui-btn-xs" data-post='{:url("$classuri/rebuild")}' data-confirm="真的要现在重建索引吗？">
        重建索引
    </button>
    {/if}
    {if auth("$classuri/del")}
    <button class="layui-btn layui-btn-xs" data-post-batch='{:url("$classuri/del")}' data-title="批量删除">批量删除</button>
    {/if}
    {if auth("$classuri/add")}
    <button class="layui-btn layui-btn-xs" data-modal='{:url("$classuri/add")}' data-title="添加文章">添加文章</button>
    {/if}
</div>
{/block}

{block name="table"}
<table class="layui-table" lay-even lay-skin="line" lay-size="sm">
    <thead>
    <tr>
        <th>
            <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
        </th>
        <th>id</th>
        <th>所属分类</th>
        <th>标题</th>
        <th>缩略图</th>
        <th>关键词</th>
        <th>描述</th>
        <th>状态</th>
        <th>更新时间</th>
        <th>操作</th>
    </thead>
    <tbody>
    {volist name="list" id="vo"}
    <tr>
        <td>
            <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{$vo.id}'><i class="layui-icon">&#xe605;</i></div>
        </td>
        <td>{$vo.id}</td>
        <td>{$vo.category.title|default="未指定分类"}</td>
        <td>{$vo.title}</td>
        <td>
            {notempty name="vo.thumb"}
            <img src="{$vo.thumb}" class="data-tips-image" alt="缩略图">
            {/notempty}
        </td>
        <td>{$vo.keyword}</td>
        <td>{$vo.description}</td>
        <td>{:$vo.state?'已启用':'已禁用'}</td>
        <td>{$vo.update_time|date='Y-m-d H:i'}</td>
        <td>
            <div class="layui-btn-group">
                {if auth("$classuri/edit")}
                <button class="layui-btn layui-btn-xs" href="javascript:;" data-title="编辑文章"
                        data-modal='{:url("$classuri/edit",["id"=>$vo.id,"cid"=>$vo.cid])}&'>
                    编辑
                </button>
                {/if}
                {if auth("$classuri/change")}
                <button class="layui-btn layui-btn-xs layui-btn-{:$vo.state?'warm':'primary'}" href="javascript:;" data-confirm="确定操作该条数据吗？"
                        data-post='{:url("$classuri/change")}' data-param='id={$vo.id}&state={:abs($vo.state-1)}'>
                    {:$vo.state?'禁用':'启用'}
                </button>
                {/if}
                {if auth("$classuri/del")}
                <button class="layui-btn layui-btn-xs" href="javascript:;"
                        data-confirm="确定要删除吗！" data-post='{:url("$classuri/del")}' data-param='ids={$vo.id}'>
                    删除
                </button>
                {/if}
            </div>
        </td>
    </tr>
    {/volist}
    </tbody>
</table>
{$page|raw}
{/block}

{block name="script"}
<!--<script src="__ADMIN__/js/browser-md5-file.js"></script>-->
<link rel="stylesheet" href="__ADMINS__/lib/editor.md/css/editormd.min.css" />
<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="__ADMINS__/lib/editor.md/editormd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ckeditor/4.11.3/ckeditor.js"></script>
{/block}